﻿using System;
using System.ComponentModel.Composition;
using System.Linq;
using Caliburn.Micro;
using SuperShell.Common.IoC.Attributes.MainScreen;
using SuperShell.Infrastructure.Screens;

namespace SuperShell.Main.ViewModels
{
	[Export(typeof (IShell))]
	public class ShellViewModel : Conductor<IMainScreen>.Collection.OneActive
	{
		public override string DisplayName
		{
			get { return "Super Shell"; }
			set { }
		}

		[ImportMany]
		public Lazy<IMainScreen, IMainScreenMetadata>[] MainScreens { get; set; }

		protected override void OnActivate()
		{
			// Basic logic: selecting first available object that represents main screen.
			// TODO: in the future this will be replaced with some special screen choosing logic
			var mainScreenLazy = MainScreens.FirstOrDefault();

			if (mainScreenLazy != null)
			{
				ActivateItem(mainScreenLazy.Value);
			}
		}
	}
}
